{% extends "base_generic.html" %}
{% block script %}
<script type="text/javascript">
  function generateUrl(name) {
    var sanitizedName = name;
    sanitizedName = sanitizedName.replace(/ el /gi, ' ');
    sanitizedName = sanitizedName.replace(/ la /gi, ' ');
    sanitizedName = sanitizedName.replace(/ los /gi, ' ');
    sanitizedName = sanitizedName.replace(/ las /gi, ' ');
    sanitizedName = sanitizedName.replace(/ de /gi, ' ');
    sanitizedName = sanitizedName.replace(/ del /gi, ' ');
    sanitizedName = sanitizedName.replace(/ temporada /gi, ' ');
    sanitizedName = string_to_slug(sanitizedName);
    sanitizedName = sanitizedName.replace(/--/gi, '-');
    sanitizedName = sanitizedName.replace(/---/gi, '-');
    sanitizedName = sanitizedName.replace(/----/gi, '-');
    $("#url").val(sanitizedName);
  }

  $(window).load(
    function() {
      arraymain = new Array();
      arraymain['imagetype']='main';
      imageUploader('mainimage', '{{filekey}}', 'addImageMain', arraymain);
      arraynormal = new Array();
      arraynormal['imagetype']='normal';
      imageUploader('normalimage', '{{filekey}}', 'addImage', arraynormal);

      $( "#avDate" ).datepicker({ dateFormat: 'yy-mm-dd 00:00:00.000000' });
    });
    

  function addImageMain(key) {
    $(".imgmain").remove();
    var strhtml="<img src=\"/image/" + key + "/\" width=\"215\" class=\"imgmain\" />";
    $('#images').append(strhtml);
  }

  function addImage(key) {
    var strhtml="<img src=\"/image/" + key + "/75/75/cropped/\" width=\"75\" height=\"75\" id=\"" + key + "\" />";
    strhtml += "<a href=\"#\" onclick=\"deleteImage('{{ image.key }}'); return false;\" class=\"image-deleter\" id=\"deleter-{{ image.key }}\">X</a>"
    $('#images').append(strhtml);
  }


  function deleteImage(key) {
    $.post('/admin/image/delete/' + key + '/');
    $('#' + key).remove();
    $('#deleter-' + key).remove();
  }

</script>
{% endblock %}
{% block content %}
        <h1>artist</h1>
        <form action="/admin/artists/{{ artistid }}/save/" method="post">
        
        <div class="line en">
          <div class="field">
            <input id="name" name="name" type="text" size="65" value="{{ name }}" onblur="generateUrl(this.value);" />
          </div>
          <div class="field">
            <input id="url" name="url" type="text" size="50" value="{{ url }}" />
          </div>
        </div>
        <div class="line en">
          <div class="field">
            <input id="letter1" name="letter1" type="text" size="1" value="{{ letter1 }}" />
            <input id="letter2" name="letter2" type="text" size="1" value="{{ letter2 }}" />
            <input id="letter3" name="letter3" type="text" size="1" value="{{ letter3 }}" />
            <input id="letter4" name="letter4" type="text" size="1" value="{{ letter4 }}" />
            <input id="letter5" name="letter5" type="text" size="1" value="{{ letter5 }}" />
            <input id="letter6" name="letter6" type="text" size="1" value="{{ letter6 }}" />
            <input id="letter7" name="letter7" type="text" size="1" value="{{ letter7 }}" />
            <input id="letter8" name="letter8" type="text" size="1" value="{{ letter8 }}" />
            <input id="letter9" name="letter9" type="text" size="1" value="{{ letter9 }}" />
            <input id="letter10" name="letter10" type="text" size="1" value="{{ letter10 }}" />
          </div>
          <div class="field">
            <input id="url" name="url" type="text" size="50" value="{{ url }}" />
          </div>
        </div>
        <div class="line">
           <div class="field">
             <input id="tags" name="tags" type="text" size="65" value="{{ tags }}" />
           </div>
        </div>

        <input type="submit" value="Guardar" id="save" name="save" /><br class="clear" />
      </form>
      <br class="clear" />

{% endblock %}
      